import * as Minio from 'minio'


function getclient() {
  var minioClient = new Minio.Client({
    endPoint: "1982.168.11.250",
    port: 19000,
    useSSL: true,
    accessKey: "fb9B6CHhUHDyHP9A",
    secretKey: "DpuphHFxUWM2EPmCMRmjBRsyltH0oxs6"
  });
  return minioClient;
}

export function uploadfile(file) {
  var metaData = {
    "Content-Type": "application/octet-stream",
    "X-Amz-Meta-Testing": 1234,
    example: 5678
  };
  var minioClient=getclient()
  // Using fPutObject API upload your file to the bucket europetrip.
  return new Promise((resolve, reject) => {

    minioClient.fPutObject("europetrip", file && file.anme, file, metaData, function(err, etag) {
      if (err) {
        reject(err);
        return console.log(err);
      }
      console.log("File uploaded successfully.");

      resolve(etag);
    });
  });

}
